package Practice;

import java.util.Scanner;

public class Tree {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int l = sc.nextInt();
        int m = sc.nextInt();
        int[] tree = new int[l+1];

        for (int i = 0; i < m; i++) {
            int u = sc.nextInt();
            int v = sc.nextInt();
            for (int j=u;j<=v;j++){
                if (tree[j]!=1){
                    tree[j] = 1;
                }
            }
        }

        int num;
        int sum = 0;
        for (int i = 0; i < l+1; i++) {
            sum += tree[i];
        }
        num = l+1-sum;
        System.out.println(num);
    }
}
